<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
  <meta name="generator" content=
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">

  <title>Escape Sequences</title>
  <link href="cppreference.css" rel="stylesheet" type="text/css">
</head>

<body>
<table>
  <tr>
  <td valign="top">
  <div class="body-content">

  <div class="header-box">
    <a href="index.html">cppreference.com</a> &gt; Escape Sequences
  </div>

  <h3>Constant Escape Sequences</h3>

  <p>The following escape sequences can be used to define certain
  special characters within strings:</p>

  <table class="misc-table">
    <tr>
      <th>Escape Sequence</th>

      <th>Description</th>
    </tr>

    <tr class="misc-table-tr-2">
      <td>\&#39;</td>

      <td>Single quote</td>
    </tr>

    <tr class="misc-table-tr-1">
      <td>\&quot;</td>

      <td>Double quote</td>
    </tr>

    <tr class="misc-table-tr-2">
      <td>\\</td>

      <td>Backslash</td>
    </tr>

    <tr class="misc-table-tr-1">
      <td>\nnn</td>

      <td>Octal number (nnn)</td>
    </tr>

    <tr class="misc-table-tr-2">
      <td>\0</td>

      <td>Null character (really just the octal number zero)</td>
    </tr>

    <tr class="misc-table-tr-1">
      <td>\a</td>

      <td>Audible bell</td>
    </tr>

    <tr class="misc-table-tr-2">
      <td>\b</td>

      <td>Backspace</td>
    </tr>

    <tr class="misc-table-tr-1">
      <td>\f</td>

      <td>Formfeed</td>
    </tr>

    <tr class="misc-table-tr-2">
      <td>\n</td>

      <td>Newline</td>
    </tr>

    <tr class="misc-table-tr-1">
      <td>\r</td>

      <td>Carriage return</td>
    </tr>

    <tr class="misc-table-tr-2">
      <td>\t</td>

      <td>Horizontal tab</td>
    </tr>

    <tr class="misc-table-tr-1">
      <td>\v</td>

      <td>Vertical tab</td>
    </tr>

    <tr class="misc-table-tr-2">
      <td>\xnnn</td>

      <td>Hexadecimal number (nnn)</td>
    </tr>
  </table>

  <p>An example of this is contained in the following code:</p>
  <pre class="example-code">
  printf( &quot;This\nis\na\ntest\n\nShe said, \&quot;How are you?\&quot;\n&quot; );
</pre>

  <p>which would display</p>
  <pre class="example-code">
  This
  is
  a
  test

  She said, &quot;How are you?&quot;
</pre>
  </div>
  </td>
  



  </tr>
  </table>
</body></html>
